/*******************************************************************************
 * Copyright (c) 2009 Philippe Marschall and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     Philippe Marschall - initial API and implementation
 *******************************************************************************/
package com.googlecode.mylyn.ui.editor;

import org.eclipse.mylyn.tasks.core.ITask;
import org.eclipse.mylyn.tasks.ui.ITasksUiConstants;
import org.eclipse.mylyn.tasks.ui.TasksUiImages;
import org.eclipse.mylyn.tasks.ui.TasksUiUtil;
import org.eclipse.mylyn.tasks.ui.editors.AbstractTaskEditorPageFactory;
import org.eclipse.mylyn.tasks.ui.editors.TaskEditor;
import org.eclipse.mylyn.tasks.ui.editors.TaskEditorInput;
import org.eclipse.swt.graphics.Image;
import org.eclipse.ui.forms.editor.IFormPage;

import com.googlecode.mylyn.core.GoogleCodeCorePlugin;
import com.googlecode.mylyn.ui.GoogleCodeUiPlugin;

public class GoogleCodePageFactory extends AbstractTaskEditorPageFactory {

    @Override
    public boolean canCreatePageFor(TaskEditorInput input) {
        ITask task = input.getTask();
        // copy and pasted from other connectors
        return (task.getConnectorKind().equals(GoogleCodeCorePlugin.CONNECTOR_KIND) || TasksUiUtil
                .isOutgoingNewTask(task, GoogleCodeCorePlugin.CONNECTOR_KIND));
    }

    @Override
    public String[] getConflictingIds(TaskEditorInput input) {
        // copy and pasted from other connectors
        if (!input.getTask().getConnectorKind().equals(GoogleCodeCorePlugin.CONNECTOR_KIND)) {
            return new String[] { ITasksUiConstants.ID_PAGE_PLANNING };
        }
        return null;
    }

    @Override
    public IFormPage createPage(TaskEditor editor) {
        return new GoogleCodeTaskEditorPage(editor);
    }

    @Override
    public int getPriority() {
        return PRIORITY_TASK;
    }

    @Override
    public Image getPageImage() {
        return GoogleCodeUiPlugin.getDefault().getImage(TasksUiImages.REPOSITORY_SMALL);
    }

    @Override
    public String getPageText() {
        // TODO translate
        return "Issue";
    }

}
